﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RH.Domain;
using RH.Web.ViewModels;
using RH.Common.Extensions;

namespace RH.Web.Utility
{
    public class ActionHelper
    {
        private AppEntities Context { get; set; }
        public ActionHelper(AppEntities context)
        {
            this.Context = context;
        }

        /// <summary>
        /// Gets a list of product ids of the currently logged in user's favorite product ids.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public List<int> GetUserFavorites()
        {
            List<int> favorites = new List<int>();
            if (SessionCache.CurrentUser != null)
            {
                favorites = (from P in this.Context.UserWishLists where P.UserID == SessionCache.CurrentUser.ID && !P.IsDeleted select P.ProductID).ToList();
            }
            return favorites;
        }
    }
}